package Jiec.electiveol;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;


public class WebServiceUtil {
	private static String NameSpace = "http://tempuri.org/";
	private static String MethodName = "doLogin_getPassword";
	private static String url = "http://172.16.36.26:9997/Elective_Servic.asmx";
	private static String soapAction = NameSpace + MethodName;
	
	public static String getPassword(String userId) {
		// TODO Auto-generated method stub
		String password = null;
		SoapObject so = new SoapObject(NameSpace, MethodName);
		SoapSerializationEnvelope sse = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		so.addProperty("id",userId);
		sse.dotNet = true;
		sse.setOutputSoapObject(so);
		HttpTransportSE hts = new HttpTransportSE(url);
		try{
			hts.call(soapAction, sse);
			if(sse.getResponse() != null){
				SoapPrimitive response = (SoapPrimitive)sse.getResponse();
				password = response.toString();
			}
		}catch(Exception e){
			password = e.getMessage();
			return password;
		}
		return password;
	}
}
